
clear all
set more off

use "data/raw/defund-sender-replication-deidentified", clear 

* Classify private support
gen join = defunding_opposition=="Yes"
lab var join "Joined campaign"

* Drop pre-randomization attritters and flag post-randomization attriters
* condition: excuse or noexcuse
drop if !inlist(condition, "excuse", "noexcuse")

gen attrit = 0
replace attrit = 1 if misleading == "" 
lab var attrit "Respondent attritted post-randomization"

* Generate outcome and treatment variables
gen posted = post=="Yes"
replace posted = . if missing(post)
lab var posted "Authorized Twitter post"
drop post 

gen excuse = condition=="excuse"
lab var excuse "Excuse condition"
gen noexcuse = condition=="noexcuse"
lab var noexcuse "No excuse condition"
drop condition


gen partisan = .
replace partisan = 2 if liberal == "Very conservative"
replace partisan = 1 if liberal == "Conservative"
replace partisan = 0 if liberal == "Neither liberal nor conservative"
replace partisan = -1 if liberal == "Liberal"
replace partisan = -2 if liberal == "Very liberal"
label var partisan "Partisan leaning"
gen ind = 0

rename misleading misleading_temp
gen misleading = misleading_temp=="Yes"
drop misleading_temp

lab var misleading "Respondent found Tweet misleading"
lab var open_misleading "Reason Tweet was misleading"

destring year, replace
gen age = 2021-year
lab var age "Age"
drop year

gen age2 = age^2
lab var age2 "Age squared"
gen hisp = hispanic=="Yes"
lab var hisp "Spanish, Hispanic, or Latino"
drop hispanic
gen male = sex == "Male"
lab var male "Male"
drop sex

lab var education "Education level"

gen white = race=="Caucasian/White"
lab var white "White"
lab var race "Race"

lab var followers "Self-reported number of followers"
lab var defundoppose "Self-reported share of audience who would oppose defunding"


** Twitter characteristics

gen num_follower_bin = .
replace num_follower_bin = 1 if followers == "0 followers" | followers == "1-10 followers" | followers == "11-25 followers"
replace num_follower_bin = 2 if followers == "26-50 followers" | followers == "51 followers-100 followers"
replace num_follower_bin = 3 if followers == "101 to 500 followers" | followers=="501 to 1000 followers" | followers == "1001+ followers"


gen perc_audi = .
replace perc_audi = 1 if defundoppose == "0-10%" | defundoppose == "10-30%"
replace perc_audi = 2 if defundoppose == "30-50%" | defundoppose == "50-70%"
replace perc_audi = 3 if defundoppose == "70-90%" | defundoppose == "90-100%"


keep attrit join posted excuse noexcuse education race partisan age age2 hisp male white misleading open_misleading followers defundoppose num_follower_bin perc_audi

save "data/working/defund-sender-replication.dta", replace
exit,clear
